package zip;

import java.io.File;

public class FileWrapper implements Comparable<Object> {
    /** File */
    private File file;
    
    public FileWrapper(File file) {
        this.file = file;
    }
     
    public int compareTo(Object obj) {
        assert obj instanceof FileWrapper;
        
        FileWrapper castObj = (FileWrapper)obj;
        String thisName = this.file.getName().toLowerCase() ;
        int length = DecompressUtil.HOTFIX_PERFIX.length();
        long thisDate = 0;
		if (thisName.startsWith(DecompressUtil.HOTFIX_PERFIX) 
				&& thisName.endsWith(DecompressUtil.HOTFIX_SUFFIX))
			thisDate = Long.valueOf((thisName.substring(length, length + 11)));
        String objName = castObj.getFile().getName().toLowerCase() ;
        long objDate = 0;
		if (objName.startsWith(DecompressUtil.HOTFIX_PERFIX) 
				&& objName.endsWith(DecompressUtil.HOTFIX_SUFFIX))
			objDate = Long.valueOf((objName.substring(length, length + 11)));
        if (thisDate >  objDate ) {
            return 1;
        } else if (thisDate <  objDate) {
            return -1;
        } else {
            return 0;
        }
    }
    
    public File getFile() {
        return this.file;
    }
}